<template>
  <div class="container" ref="mainCon">
    <topTitle titleText="考核自评"></topTitle>
    <div class="mainCon">
      <el-row class="toolbar searchInputWidth" style="padding-bottom: 0">
        <el-form :inline="true">
          <el-col :lg="8" :xl="6">
            <el-form-item label="考核名称" class="row-padding-bottom">
              <el-input
                v-model="filterField.name"
                placeholder="请输入考核名称"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-form-item>
            <!-- <el-button type="primary" icon="icon iconfont iconchazhao1" @click="searchList" class="commonBtn"></el-button> -->
            <el-button
              type="primary"
              icon="icon iconfont iconchazhao1"
              @click="searchList"
              class="searchBtn"
            >
              <span>搜索</span>
            </el-button>
          </el-form-item>
          <el-form-item>
            <exportBtn
              :dataLen="tableList.length"
              :filterField="filterField"
              api="api-s/report/export_JC_ZS_SELF_ASSESS"
            ></exportBtn>
          </el-form-item>
        </el-form>
      </el-row>
      <div class="spacing"></div>
      <div
        ref="tableBox"
        :class="hiddleToolBar ? 'tableBoxCur tableBox' : 'tableBoxCur'"
      >
        <el-table
          ref="tableBox1"
          :max-height="tableHeight"
          @sort-change="sortChange"
          :data="tableList"
          v-loading="loading"
          :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
          highlight-current-row
          stripe
          style="border: 1px solid #dfe6ec"
        >
          <el-table-column prop="name" label="考核名称" width="230">
            <template slot-scope="scope">
              <copyText
                :tableIndex="scope.$index"
                :copyTextName="scope.row.name"
                :columnName="'name'"
              ></copyText>
            </template>
          </el-table-column>
          <!-- <el-table-column prop="assessAreaName" label="被考核地区" align="center" :formatter=formatTd></el-table-column> -->
          <el-table-column prop="assessAreaName" label="被考核地区" width="230">
            <template slot-scope="scope">
              <copyText
                :tableIndex="scope.$index"
                :copyTextName="scope.row.assessAreaName"
                :columnName="'assessAreaName'"
              ></copyText>
            </template>
          </el-table-column>
          <el-table-column
            prop="expireDate"
            label="自评截止日期"
            sortable="custom"
            align="center"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column label="考核自评进展" align="center">
            <template slot-scope="scope">
              {{ scope.row.selfEvaluateRate }}/{{ scope.row.total }}
            </template>
          </el-table-column>
          <el-table-column
            label="操作"
            align="left"
            :formatter="formatTd"
            width="110"
            fixed="right"
          >
            <template slot-scope="scope">
              <el-link
                type="primary"
                @click="toProof(scope.row)"
                v-if="isShowProof"
                >自评举证</el-link
              >
              <el-link type="primary" v-else>--</el-link>
            </template>
          </el-table-column>
          <!-- 表格数据为空时，页面显示 -->
          <div slot="empty" v-show="isShow">
            <emptyTable emptyText="暂无相关信息"></emptyTable>
          </div>
        </el-table>
        <!-- getTableList为获取子组件的数据 -->
        <Pagination
          ref="pagination"
          @getList="getTableList"
          :filterField="filterField"
          :requestUrl="requestUrl"
        ></Pagination>
      </div>
    </div>
  </div>
</template>
<script>
import scrollTable from '@/mixin/scrollTable.js'
export default {
  name: 'selfEvalution',
  mixins: [scrollTable],
  data() {
    return {
      name: '',
      //表格数据
      tableList: [],
      filterField: {
        name: '',
      },
      requestUrl: 'api-gov/assess/expand/selfassesspage',
      isShow: false, //列表加载
      // loading: true,
      loading: false,
      isShowProof: '',
    }
  },
  activated: function () {},
  created() {
    this.$nextTick(function () {
      this.$refs.pagination.getTableListData()
    })
    this.isShowProof =
      this.$store.state.buttonLimitsArr.indexOf('checkSelfEvalution:update') >
      -1
  },
  methods: {
    // 搜索
    searchList() {
      this.$refs.pagination.getTableListData()
    },
    dateMinus(date1, date2) {
      var sdate = new Date(date1)
      var now = new Date(date2)
      var days = now.getTime() - sdate.getTime()
      var day = parseInt(days / (1000 * 60 * 60 * 24))
      return day
    },
    formatNowDate() {
      var d = new Date(),
        month = '' + (d.getMonth() + 1),
        day = '' + d.getDate(),
        year = d.getFullYear()
      if (month.length < 2) month = '0' + month
      if (day.length < 2) day = '0' + day
      return [year, month, day].join('-')
    },
    getTableList(data) {
      this.tableList = data
      this.loading = false
      if (this.tableList.length < 1) {
        this.isShow = true
      }
    },
    toProof(rowData) {
      this.$router.push({
        path: '/home/checkAffairs/selfEvalutionProofList',
        name: 'selfEvalutionProofList',
        query: {
          id: rowData.id,
        },
      })

      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl: '/home/checkAffairs/checkSelfEvalution',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
  },
}
</script>

<style scoped lang="less">
@import '../../../static/css/filterArea.less';
.topTitle {
  height: 67px;
  background-color: #e4ebf1;
  padding-left: 24px;
  font-weight: bold;
  font-size: 18px;
  line-height: 67px;
  color: #333;
  .saveBtn {
    margin-right: 24px;
    margin-top: 15.5px;
  }
}
.nav ul {
  list-style: none;
}

.nav li {
  display: block;
  float: left;
}
/deep/ .el-dialog__footer {
  background: #fff;
  padding-bottom: 70px;
}
</style>
